package cn.rocky.pandacodegen.common;

import lombok.Getter;
import lombok.Setter;

public class R<T> {

    /**
     * 状态码
     */
    @Getter
    @Setter
    private int code;

    @Getter
    @Setter
    private T data;

    /**
     * 状态码 成功
     */
    private static final int CODE_SUCCESS = 0;
    /**
     * vue 框架返回
     */
    public  static final int CODE_VUE = 20000;
    
    public  R<T> ok() {
        return new R<>();
    }

    public  R<T> ok(T data) {
        R<T> r = new R<>();
        r.setCode(CODE_VUE);
        r.setData(data);
        return r;
    }

    public R<T> ok(int code, T data) {
        R<T> r = new R<>();
        r.setCode(code);
        r.setData(data);
        return r;
    }

}
